<?php
/**
 * 検索　共通コントローラクラス<br />
 *
 * @package apamanshop
 * @author SS永田
 * @copyright コピーライト(要確認)
 */
abstract class Search_BaseController extends Apm_Controller_Base
{

	/*
	 * 表示テンプレート
	 */

	protected $_main_contents_helper             = null;    //メイン
	protected $_header_helper                    = null;    //ヘッダー
	protected $_research_leftpanel_helper        = null;    //左ペイン上部：再検索
    protected $_basic_leftpanel_helper           = null;    //左ペイン中部：基本条件
    protected $_kodawari_leftpanel_helper        = null;    //左ペイン下部：こだわり条件
	protected $_shinchaku_leftpanel_helper 		= null;     //左ペイン追加 2013/02/14：新着リンク
    protected $_todohuken_helper                 = null;    //都道府県選択
    protected $_todohuken_mypage_helper          = null;    //都道府県選択 マイページ用
    protected $_todohuken_radio_helper           = null;    //都道府県_単一選択
    protected $_todohuken_radio_selsrh_helper    = null;    //都道府県_単一選択_検索選択
    protected $_todohuken_request_helper         = null;    //都道府県選択 物件リクエスト用
    protected $_todohuken_houzin_helper          = null;    //都道府県選択 社宅検索用
    protected $_todohuken_houzinrequest_helper   = null;    //都道府県選択 社宅物件リクエスト用
    protected $_shikucyoson_helper               = null;    //市区町村選択
    protected $_shikucyoson2_helper               = null;    //市区町村選択
    protected $_shikucyoson_otakara_helper       = null;    //市区町村選択_お宝キャンペーン用
    protected $_shikucyoson_request_helper       = null;    //市区町村選択 物件リクエスト用
    protected $_shikucyoson_houzin_helper        = null;    //市区町村選択 社宅検索用
    protected $_shikucyoson_houzinrequest_helper = null;    //市区町村選択 社宅物件リクエスト用
    protected $_sikucyoson_chizu_helper          = null;    //市区町村_地図選択
    protected $_shikucyoson_campaign_helper      = null;    //市区町村選択_キャンペーン用
    protected $_cyo_helper                       = null;    //町選択
    protected $_cyo_request_helper               = null;    //町選択 物件リクエスト用
    protected $_cyo_houzin_helper                = null;    //町選択 社宅検索用
    protected $_cyo_houzinrequest_helper         = null;    //町選択 社宅物件リクエスト用
    protected $_ensen_helper                     = null;    //沿線選択
    protected $_ensen_request_helper             = null;    //沿線選択 物件リクエスト用
    protected $_ensen_houzin_helper              = null;    //沿線選択 社宅検索用
    protected $_ensen_houzinrequest_helper       = null;    //沿線選択 社宅物件リクエスト用
    protected $_eki_helper                       = null;    //駅選択
    protected $_eki_request_helper               = null;    //駅選択 物件リクエスト用
    protected $_eki_houzin_helper                = null;    //駅選択 社宅検索用
    protected $_eki_houzinrequest_helper         = null;    //駅選択 社宅物件リクエスト用
    protected $_eki_rosenzu_helper               = null;    //駅_路線図選択
    protected $_inputekiname_helper              = null;    //駅名入力
    protected $_selekiname_helper                = null;    //駅名入力選択
    protected $_selekiname_map_helper            = null;    //駅名入力選択（地図検索）
    protected $_tsukintsugaku_jikan_helper       = null;    //通勤・通学時間選択
    protected $_freeword_helper                  = null;    //フリーワード入力
    protected $_johosino_helper                  = null;    //情報誌NO入力
    protected $_gakkoname_helper                 = null;    //学校名入力
    protected $_gakko_helper                     = null;    //学校選択
    protected $_rireki_hyoji_helper              = null;    //前回閲覧履歴表示
    protected $_okiniiri_hyoji_helper            = null;    //お気に入り表示
    protected $_yachinsouba_sikucyoson_helper    = null;    //家賃相場（市区町村）
    protected $_yachinsouba_ensen_helper         = null;    //家賃相場（沿線）
    protected $_yachinsouba_sikucyoson_syosai_helper = null;//家賃相場（市区町村）詳細
    protected $_yachinsouba_for_rstdtl_helper    = null;    //家賃相場（物件詳細）
    protected $_yachinsouba_for_rosenzu_helper   = null;    //家賃相場（路線図）
    protected $_chinryomadori_helper             = null;    //賃料×間取り
    protected $_kodawari_list_helper             = null;    //全国こだわり物件
    protected $_kodawari_selpref_helper          = null;    //こだわり物件（都道府県選択）
    protected $_kodawari_selpref_38_helper       = null;    //こだわり物件（災害時住宅支援LP）
    //protected $_kodawari_selpref_39_helper       = null;    //こだわり物件（特別優遇物件LP）
    protected $_wakeari_tokusyu_helper           = null;    //わけあり物件特集
    protected $_chizu_helper                     = null;    //地図検索結果画面
    protected $_rstobi_chizu_helper              = null;    //地図検索物件一覧
    protected $_area_helper                      = null;    //エリア検索
    protected $_area_tenpo_helper                = null;    //エリア検索（店舗一覧）
	protected $_jyohoshino_nodata_helper         = null;    //情報誌No.


	protected $_kodawari_popkodawari_helper      = null;    //人気のこだわり条件
	protected $_kodawari_jokenlist_helper        = null;    //こだわり条件一覧
	protected $_seo_notice_new_bkn_helper        = null;    //注目の新着物件情報

	protected $_newTemplate = false;

    /**
     * 初期処理
     */
    public function preDispatch()
    {
        /*** ヘルパーの生成 【ここから】***/

    	/*
    	 * 表示テンプレート
    	 */
    	$this->_main_contents_helper          = $this->getApmHelper('main_contents.tpl');             //メイン
    	$this->_research_leftpanel_helper     = $this->getApmHelper('research_leftpanel.tpl');        //左ペイン上部：再検索
        $this->_basic_leftpanel_helper        = $this->getApmHelper('selbasic_leftpanel.tpl');        //左ペイン中部：基本条件
        $this->_kodawari_leftpanel_helper     = $this->getApmHelper('selkodawari_leftpanel.tpl');     //左ペイン下部：こだわり条件
        $this->_shinchaku_leftpanel_helper    = $this->getApmHelper('search/views/helpers/shinchakuLink.tpl');  //2013/02/14 左ペイン追加新着リンク
        $this->_todohuken_helper              = $this->getApmHelper('seltodohuken.tpl');              //都道府県選択
        $this->_todohuken_mypage_helper       = $this->getApmHelper('seltodohuken_mypage.tpl');       //都道府県選択 マイページ用
        $this->_todohuken_request_helper      = $this->getApmHelper('seltodohuken_request.tpl');      //都道府県選択 物件リクエスト用
        $this->_todohuken_request_easy_helper = $this->getApmHelper('seltodohuken_request_easy.tpl'); //都道府県選択 物件リクエスト用
        $this->_todohuken_houzin_helper       = $this->getApmHelper('seltodohuken_houzin.tpl');       //都道府県選択 社宅検索用
        $this->_todohuken_houzinrequest_helper = $this->getApmHelper('seltodohuken_houzinrequest.tpl'); //都道府県選択 社宅物件リクエスト用
        $this->_shikucyoson_helper            = $this->getApmHelper('selsikucyoson.tpl');             //市区町村選択
        $this->_shikucyoson2_helper            = $this->getApmHelper('selsikucyoson2.tpl');             //市区町村選択
        $this->_shikucyoson_otakara_helper    = $this->getApmHelper('selsikucyoson_otakara.tpl');     //市区町村選択 お宝キャンペーン
        $this->_shikucyoson_request_helper    = $this->getApmHelper('selsikucyoson_request.tpl');     //市区町村選択 物件リクエスト用
        $this->_shikucyoson_request_easy_helper  = $this->getApmHelper('selsikucyoson_request_easy.tpl');     //市区町村選択 物件リクエスト用
        $this->_shikucyoson_houzin_helper     = $this->getApmHelper('selsikucyoson_houzin.tpl');      //市区町村選択 社宅検索用
        $this->_shikucyoson_houzinrequest_helper = $this->getApmHelper('selsikucyoson_houzinrequest.tpl'); //市区町村選択 社宅物件リクエスト用
        $this->_shikucyoson_campaign_helper   = $this->getApmHelper('selsikucyoson_campaign.tpl');    //市区町村選択 キャンペーン
        $this->_cyo_helper                    = $this->getApmHelper('selcyo.tpl');                    //町選択
        $this->_cyo_request_helper            = $this->getApmHelper('selcyo_request.tpl');            //町選択 物件リクエスト用
        $this->_cyo_houzin_helper             = $this->getApmHelper('selcyo_houzin.tpl');             //町選択 社宅検索用
        $this->_cyo_houzinrequest_helper      = $this->getApmHelper('selcyo_houzinrequest.tpl');      //町選択 社宅物件リクエスト用
        $this->_ensen_helper                  = $this->getApmHelper('selensen.tpl');                  //沿線選択
        $this->_ensen_request_helper          = $this->getApmHelper('selensen_request.tpl');          //沿線選択 物件リクエスト用
        $this->_ensen_request_easy_helper     = $this->getApmHelper('selensen_request_easy.tpl');          //沿線選択 物件リクエスト用
        $this->_ensen_houzin_helper           = $this->getApmHelper('selensen_houzin.tpl');           //沿線選択 社宅検索用
        $this->_ensen_houzinrequest_helper    = $this->getApmHelper('selensen_houzinrequest.tpl');    //沿線選択 社宅物件リクエスト用
        $this->_eki_helper                    = $this->getApmHelper('seleki.tpl');                    //駅選択
        $this->_eki_request_helper            = $this->getApmHelper('seleki_request.tpl');            //駅選択 物件リクエスト用
        $this->_eki_request_easy_helper       = $this->getApmHelper('seleki_request_easy.tpl');       //駅選択 物件リクエスト用
        $this->_eki_houzin_helper             = $this->getApmHelper('seleki_houzin.tpl');             //駅選択 社宅検索用
        $this->_eki_houzinrequest_helper      = $this->getApmHelper('seleki_houzinrequest.tpl');      //駅選択 社宅物件リクエスト用
        $this->_sikucyoson_chizu_helper       = $this->getApmHelper('selsikucyoson_chizu.tpl');       //市区町村_地図選択
        $this->_todohuken_radio_helper        = $this->getApmHelper('seltodohuken_radio.tpl');        //都道府県_単一選択
        $this->_eki_rosenzu_helper            = $this->getApmHelper('seleki_rosenzu.tpl');            //駅_路線図選択
        $this->_inputekiname_helper           = $this->getApmHelper('inputekiname.tpl');              //駅名入力
        $this->_selekiname_helper             = $this->getApmHelper('selekiname.tpl');                //駅名入力選択
        $this->_selekiname_map_helper         = $this->getApmHelper('selekiname_map.tpl');            //駅名入力選択（地図検索）
        $this->_tsukintsugaku_jikan_helper    = $this->getApmHelper('seltsukintusgaku_jikan.tpl');    //通勤・通学時間選択
        $this->_freeword_helper               = $this->getApmHelper('inputfreeword.tpl');             //フリーワード入力
        $this->_johosino_helper               = $this->getApmHelper('inputjohosino.tpl');             //情報誌NO入力
        $this->_gakkoname_helper              = $this->getApmHelper('inputgakkoname.tpl');            //学校名入力
        $this->_gakko_helper                  = $this->getApmHelper('selgakko.tpl');                  //学校選択
        $this->_todohuken_radio_selsrh_helper = $this->getApmHelper('seltodohuken_radio_selsrh.tpl'); //都道府県_単一選択_検索選択
        $this->_rireki_hyoji_helper           = $this->getApmHelper('rireki_hyouji.tpl');             //前回閲覧履歴表示
        $this->_okiniiri_hyoji_helper         = $this->getApmHelper('okiniiri_hyouji.tpl');           //お気に入り表示
        $this->_selbasic_helper               = $this->getApmHelper('selbasic.tpl');                  //基本・こだわり検索
        $this->_selbasic_easy_helper          = $this->getApmHelper('selbasic_easy.tpl');             //基本・こだわり検索
        $this->_selbasic_houzin_helper        = $this->getApmHelper('selbasic_houzin.tpl');           //基本・こだわり検索
        $this->_yachinsouba_sikucyoson_helper = $this->getApmHelper('yachinsouba_sikucyoson.tpl');    //家賃相場（市区町村）
        $this->_yachinsouba_ensen_helper      = $this->getApmHelper('yachinsouba_ensen.tpl');         //家賃相場（沿線）
        $this->_yachinsouba_sikucyoson_syosai_helper = $this->getApmHelper('yachinsouba_sikucyoson_syosai.tpl');    //家賃相場（市区町村）詳細
        $this->_yachinsouba_ensen_syosai_helper = $this->getApmHelper('yachinsouba_ensen_syosai.tpl');//家賃相場（市区町村）詳細
        $this->_yachinsouba_for_rstdtl_helper = $this->getApmHelper('yachinsouba_for_rstdtl.tpl');    //家賃相場（物件詳細）詳細
        $this->_yachinsouba_for_rosenzu_helper = $this->getApmHelper('yachinsouba_for_rosenzu.tpl');  //家賃相場（路線図）詳細
        $this->_chinryomadori_helper          = $this->getApmHelper('chinryomadori.tpl');             //賃料×間取り
        $this->_kodawari_list_helper          = $this->getApmHelper('kodawari_list.tpl');             //全国こだわり物件
        $this->_kodawari_selpref_helper       = $this->getApmHelper('kodawari_selpref.tpl');          //こだわり物件（都道府県選択）
        $this->_kodawari_selpref_38_helper    = $this->getApmHelper('kodawari_selpref_38.tpl');       //こだわり物件（災害時住宅支援LP）
        //$this->_kodawari_selpref_39_helper    = $this->getApmHelper('kodawari_selpref_39.tpl');       //こだわり物件（特別優遇物件LP）
        $this->_wakeari_tokusyu_helper        = $this->getApmHelper('wakeari_tokusyu.tpl');           //わけあり物件特集
        $this->_chizu_helper                  = $this->getApmHelper('chizu.tpl');                     //地図検索結果画面
        $this->_rstobi_chizu_helper           = $this->getApmHelper('rstobi_chizu.tpl');              //地図検索物件一覧
        $this->_area_helper                   = $this->getApmHelper('selarea.tpl');                   //エリア検索
        $this->_area_tenpo_helper             = $this->getApmHelper('selarea_tenpo.tpl');             //エリア検索（店舗一覧）
        $this->_jyohoshino_nodata_helper      = $this->getApmHelper('inputjyohoshino_nodata.tpl');    //情報誌No.

        $this->_kodawari_popkodawari_helper   = $this->getApmHelper('kodawari_popkodawari.tpl');      //人気のこだわり条件
        $this->_kodawari_jokenlist_helper     = $this->getApmHelper('kodawari_jokenlist.tpl');        //こだわり条件一覧
        $this->_seo_notice_new_bkn_helper     = $this->getApmHelper('seo_notice_new_bkn.tpl');        //注目の新着物件情報
		//加盟店ページ用ヘッダフッタ画面	/* 2011/07/22　AKBｷｬﾝﾍﾟｰﾝ：加盟店ﾒﾝﾊﾞｰｻｲﾄ追加対応 */
		$this->_shoppage_header_helper  = $this->getApmHelper(APPLICATION_PATH . '/modules/shop/views/helpers/shoppage/pageheader_helper.tpl');
		$this->_shoppage_footer_helper  = $this->getApmHelper(APPLICATION_PATH . '/modules/shop/views/helpers/shoppage/pagefooter_helper.tpl');

        /*** ヘルパーの生成 【ここまで】***/

		$this->_display_path      = "";
		$this->_main_helper       = null;
		$this->_static_params     = null;
		$this->_static_pattern    = "";
		$this->_static_category   = "";
		$this->_SrhKbn            = "";
		$this->_controller        = "";
		$this->_isInline          = false;	// インラインモード
		$this->_noMakeBreadcrumb  = false;	// パンくず作成しない（表示はする）
		$this->_noLeftPanel       = false;	// 左パネル不要
		$this->_disabledLeftPanel = true;	// 基本条件・こだわり条件のクローズ

		$this->_baseurl    = $this->_config['apm']['baseurl'];
		$this->_aplbaseurl = $this->_config['apm']['apl']['static']['baseurl'];

        // 共通モデルインスタンス生成
		if(empty($this->_model_common)){
        	$this->_model_common = new Search_Model_Common();
		}
        $this->_model_eki = new Search_Model_Seleki();

        // パラメータの取得
        if(empty($this->_params)){
        	$this->_params = $this->getParameters();
        }

		/*** 静的URL対応【ここから】 ***/
		// 静的URLから遷移した際、欠如している検索パラメータをここでセットする
		Apm_Bukkenurl::getParamFromStaticUrl($this->_params);
		//$this->_model_common->_getParamFromStaticUrl($this->_params);
		// パラメータを変換
		Apm_Bukkenurl::convertSearchParam($this->_params);
		//$this->_model_common->_convertSearchParam($this->_params);
		if (isset($this->_params['Pattern'])) {
			$this->_static_params   = $this->_params;
			$this->_static_pattern  = $this->_model_common->returnValue($this->_params, 'Pattern');
			$this->_static_category = $this->_model_common->returnValue($this->_params, 'Category');
			unset($this->_params['Pattern']);
			unset($this->_params['Category']);
		}

		/*** 静的URL対応【ここまで】 ***/

		// インラインモードか
		if (isset($this->_params['isInline'])) {
			if ($this->_params['isInline'] == "1") {
				$this->_isInline = true;
			}
			//unset($this->_params['isInline']);
		}

		//グローバルナビ以外の検索導線に遷移した場合、グローバルナビ用セッションクリア
		// 静的URL（住所、沿線・駅）を除く
		if ($this->_static_pattern != "chiiki" && $this->_static_pattern != "station" && !$this->_isInline) {
			$mcName = Apm_Util::getModuleControllerName();
			Apm_Util_GlobalNavi_Common::deleteSessionValue($mcName[0], $mcName[1]);
		}
		// 静的URL遷移を挟んだ場合、グローバルナビパラメータが消えるのを復活させる
		if ($this->_static_pattern == "chiiki" || $this->_static_pattern == "station") {
			Apm_Util_GlobalNavi_Common::setBasicParamsForRstobi($this->_params);
		}
    }

    /**
     * 後処理
     */
	public function postDispatch()
	{
		// リクエストデータ設定
		//  左ペインの中で使用するので、ここで設定しておく。
		if ($this->isGlobalNavi()){
			$this->_data['request'] = $this->_params;
		} else {
			$this->_data['request'] = $this->getParameters();
		}
		// 都道府県別キャンペーン対応
		if (!(array_key_exists('isMobile', $this->_params) && $this->_params['isMobile'] == 1)					// APIでない
			&& !((array_key_exists('OemCd', $this->_params)) && (is_null($this->_params['OemCd']) == false))	// OEMでない
			&& $this->_params['SrhKbn'] != Apm_Config_Search::SRHKBN_SYATAKU									// 社宅でない
			&& (array_key_exists('PrefCd', $this->_params))
		   )
		{
			if (is_array($this->_params['PrefCd'])) {
				foreach ($this->_params['PrefCd'] as $PrefCd) {
					if ($PrefCd >= '50' and $PrefCd <= '53') $PrefCd = '01';
					$this->_data['bnr_pref_'.$PrefCd] = 'on';
				}
			} else {
				$this->_data['bnr_pref_'.$this->_params['PrefCd']] = 'on';
			}
		}

		if ($this->_isInline) {
			$this->setXPassThroutgh();
		} else if ($this->_data['no_left_pane'] != '1') {

			// 左ペインが不要か
			if (!$this->_noLeftPanel) {

				// 左ペイン上部：再検索パネルの取得
				$this->_model_research = new Search_Model_ResearchPanel();
				$this->_data['research_data'] = $this->_model_research->convertResarchPanel($this->_params['SrhKbn'], $this->_params);

				// 左ペイン中部：キャンペーン取得
				if (empty($this->_params['ComId'])) {
					$this->_model_campain = new Search_Model_Campaignsearch();
					$this->_data['campaign'] = $this->_model_campain->getCampaignsearch();
					$this->_model_campain->convertData2($this->_params, $this->_data);
				}

				if (!$this->_disabledLeftPanel) {

					// 左ペイン中部：基本条件CHECKED設定
					$this->_model_basic = new Search_Model_Basicjyoken();
					$this->_data['basic'] = $this->_model_basic->setChecked($this->_params);

					// 左ペイン下部：こだわり条件データ取得
					$this->_model_kodawari = new Search_Model_Kodawarijyoken();
					$this->_data['kodawari'] = $this->_model_kodawari->getKodawariJyoken($this->_params);
					$this->_model_kodawari->convertKodawariData($this->_params, $this->_data);

					// 「初期費用」、「基本条件」、「こだわり条件」を開く
					$this->_data['left_basic_display_flg']    = false;
					$this->_data['left_kodawari_display_flg'] = false;
					$this->_data['left_cost_display_flg']     = false;

				} else {

					// 検索導線時には左ペイン「初期費用」、「基本条件」、「こだわり条件」は閉じる
					$this->_data['left_basic_display_flg']    = true;
					$this->_data['left_kodawari_display_flg'] = true;
					$this->_data['left_cost_display_flg']     = true;

				}
				// 左ペイン下部：アパログブロック
				Apm_Seo::generateApalogBlock($this->_data, $this->_params, $this->_data['research_data']);

				// パラメータのhiddenタグ生成
				$this->_data['hiddenTag'] = Apm_Util::generateHiddenTag($this->_params);
				/*
				 * テンプレート変数生成
				 */
				if ($this->_newTemplate) {
					$this->_research_leftpanel_helper = $this->getApmHelper('research_leftpanel_new.tpl');        //左ペイン上部：再検索
					$this->_basic_leftpanel_helper    = $this->getApmHelper('selbasic_leftpanel_new.tpl');        //左ペイン中部：基本条件
					$this->_kodawari_leftpanel_helper = $this->getApmHelper('selkodawari_leftpanel_new.tpl');     //左ペイン下部：こだわり条件
				}
				// 左ペイン上部：再検索
				$this->_data['menu1_block'] = $this->_research_leftpanel_helper->getBlock($this->_data);
				// 左ペイン中部：基本条件
				$this->_data['menu2_block'] = $this->_basic_leftpanel_helper->getBlock($this->_data);
				// 左ペイン下部：こだわり条件
				$this->_data['menu3_block'] = $this->_kodawari_leftpanel_helper->getBlock($this->_data);

			} else {

				// 「初期費用」、「基本条件」、「こだわり条件」は閉じる
				$this->_data['left_basic_display_flg']    = true;
				$this->_data['left_kodawari_display_flg'] = true;
				$this->_data['left_cost_display_flg']     = true;

			}

			// パンくずの設定
			$this->_setBreadcrumb();
		}

		// 検索区分の設定
		$this->_data['search_kbn'] = $this->_SrhKbn;

		// フォームのアクション名の設定
		if (empty($this->_data['form_act'])) {
			$this->_data['form_act'] = $this->_controller;
		}

		// パラメータのhiddenタグ生成
		if (isset($this->_params['research_url'])) unset($this->_params['research_url']);
		$this->_data['hiddenTag'] = Apm_Util::generateHiddenTag($this->_params);

		// タイトル、Description、Keywords設定
		$meta_data = Apm_Bukkenurl::setCommonMeta($this->_SrhKbn, $this->_params, $this->_data['research_data']);
		$this->setTitle($meta_data['new_title']);
		$this->setDescription($meta_data['new_description'],false);
		$this->setKeywords($meta_data['new_keywords']);

		// ページ見出し設定
		if (!empty($meta_data['new_h1_title'])) $this->_data['h1_title'] = $meta_data['new_h1_title'];
		$this->_data['read_title']  = $meta_data['description'];
		$this->_data['unique_text'] = $meta_data['new_unique_text'];
		// ブロック見出し設定
		if (!empty($this->_data['block_title'])) {
			if (substr($this->_data['block_title'],0,1) == '*') {
				$this->_data['block_title'] = substr($this->_data['block_title'],1);
			} else {
				$str = $meta_data['page_title'];
				if (empty($str)) {
					$this->_data['block_title'] = '';
				} else {
					$this->_data['block_title'] = $str.'を'.$this->_data['block_title'];
				}
			}
			if (Apm_Bukkenurl::checkSeoData(Apm_Config_Search::SEOSTR_TYPE, $meta_data)) {
				$this->_data['block_title'] = str_replace(Apm_Config_Search::SEOSTR_KODAWARI, Apm_Config_Search::ALIAS_KODAWARI, $this->_data['block_title']);
			}
			Apm_Bukkenurl::convertSeoText($this->_data['block_title'], $meta_data);
		}
		// ブロックリード文設定
		if (!empty($this->_data['block_text'])) {
			if (!empty($meta_data['Arias_Type'])) {
				if (Apm_Bukkenurl::checkSeoData(Apm_Config_Search::SEOSTR_TYPE, $meta_data)) {
					$this->_data['block_text'] = str_replace(Apm_Config_Search::SEOSTR_KODAWARI, Apm_Config_Search::ALIAS_KODAWARI, $this->_data['block_text']);
				}
				Apm_Bukkenurl::convertSeoText($this->_data['block_text'], $meta_data);
			} else {
				$this->_data['block_text'] = '';
			}
		}
		// 町名絞り込み画面の場合はブロック設定をページ設定へ
		if (!empty($this->_data['CityMore'])) {
			$this->setTitle($this->_data['block_title'].'｜アパマンショップ'.Apm_Config_Search::TITLE_ADDTAIL);
			$meta_data['page_title']    = $this->_data['block_title'];
			$this->_data['h1_title']    = $this->_data['block_title'];
			$this->_data['block_title'] = str_replace('絞り込む', 'さらに絞り込む', $this->_data['block_title']);
			$this->_data['block_text']  = str_replace('絞り込む', 'さらに絞り込む', $this->_data['block_text']);
		}

		// アンカー
		$this->setAnchorLink2(ltrim($meta_data["page_title"].'&nbsp;',' ').'ページトップへ');
		//$this->setAnchorLink('<p class="pagetop"><a href="javascript:backToTop()"><strong>'.ltrim($meta_data["page_title"].' ',' ').'ページのトップへ</strong></a></p>');

		// 店舗リストへのリンク生成
		if ($this->_static_pattern == 'chiiki' && ( $this->_static_category == '1' ||  $this->_static_category == '2'))
		{
			$areaTenpo = array();
			if ($this->_static_category == '1') {
				// エリアCat1
				$areaTenpo['area_name'] = Apm_Bukkenurl::getSeoData(Apm_Config_Search::SEOSTR_AREASTR, $meta_data);
				$areaTenpo['tenpo_url'] = Apm_Config_Shop::URL_TELLIST_INDEX.'?AreaCd='.$this->_params['AreaCd'];
			} else if ($this->_static_category == '2') {
				$areaTenpo['area_name'] = Apm_Bukkenurl::getSeoData(Apm_Config_Search::ALIAS_PREFSTR, $meta_data);
				$areaTenpo['tenpo_url'] = Apm_Config_Shop::URL_TELLIST_INDEX.'?PrefCd[]='.$this->_params['PrefCd'][0];
			}
			if (!empty($areaTenpo)) {
				if ($this->_newTemplate) {
					$this->_area_tenpo_helper = $this->getApmHelper('selarea_tenpo_new.tpl');
				}
				$this->_data['area_tenpo_block'] = $this->_area_tenpo_helper->getBlock($areaTenpo);
			}
		}
		// 現在の検索条件ブロック生成
		if (!$this->_newTemplate) {
			if (!empty($this->_static_pattern) && empty($this->_data['CityMore'])
			   && !in_array($this->_params['KodawariId'], Apm_Config_Search::$KODAWARI_SEO_NG_LIST))
			{
				$this->_data['seo_joken'] = array();
				Apm_Seo::generateJokenBlock($this->_data['seo_joken'], $this->_static_pattern, $this->_static_category, $this->_static_params, $meta_data);
				if (!empty($this->_data['seo_joken'])) {
					// データがある場合、ブロック生成
					$seo_now_joken_helper           = $this->getApmHelper('seo_now_joken.tpl');
					$this->_data['seo_joken_block'] = $seo_now_joken_helper->getBlock($this->_data['seo_joken']);
				}
			}
		}
		// 注目の新着物件情報ブロック生成
		if (!$this->_newTemplate) {
			if (!empty($this->_static_pattern) && empty($this->_data['CityMore'])
			   && !in_array($this->_params['KodawariId'], Apm_Config_Search::$KODAWARI_SEO_NG_LIST))
			{
				$this->_data['notice_new_bkn'] = array();
				Apm_Seo::getNoticeNewBknBlock($this->_data['notice_new_bkn'], $this->_params, $this->_SrhKbn, $meta_data);
				if (count($this->_data['notice_new_bkn']["DATA"]) > 0 ) {
					//注目の新着物件情報が1件以上あればブロックを生成する
					$notice_helper = $this->getApmHelper('seo_notice_new_bkn.tpl');
					$this->_data['notice_block'] = $notice_helper->getBlock($this->_data);
				}
			}
		}
		// SEOブロック生成
		if (!in_array($this->_params['KodawariId'], Apm_Config_Search::$KODAWARI_SEO_NG_LIST))
		{
			if(!empty($this->_static_pattern) && empty($this->_data['CityMore'])) {
				$this->_data['cross_search'] = array();
				Apm_Seo::getSeoBlock($this->_data['cross_search'], $this->_params, $this->_SrhKbn, $meta_data);
				// 沿線・駅Cat1の場合のみテンプレートが違う
				if ($this->_static_pattern == 'station' && $this->_static_category == '1')
				{
					if ($this->_newTemplate) {
						$seo_cross_helper = $this->getApmHelper('seo_pop_eki_new.tpl');
					} else {
						$seo_cross_helper = $this->getApmHelper('seo_pop_eki.tpl');
					}
						$this->_data['seo_block_eki'] = $seo_cross_helper->getBlock($this->_data);
				}
				// こだわりCat1の場合（左カラム追加によりテンプレート統一したら必要無くなるかも？）
				else if (($this->_static_pattern == 'kodawari' && $this->_static_category == '1') || ($this->_static_pattern == 'x3'))
				{
					if (!$this->_newTemplate) {
						$seo_cross_helper = $this->getApmHelper('cross_search_kodawari.tpl');
						$this->_data['seo_block'] = $seo_cross_helper->getBlock($this->_data);
					}
				}
				else
				{
					if ($this->_newTemplate) {
						$seo_cross_helper = $this->getApmHelper('cross_search_new.tpl');
					} else {
						if (Apm_Config_Search::RENEW_2012) $this->addMetaJs('/js/common/common.js');
						$seo_cross_helper = $this->getApmHelper('cross_search.tpl');
					}
					$this->_data['seo_block'] = $seo_cross_helper->getBlock($this->_data);
				}
			}
		}

		// OEM検索の場合、ヘッダー・フッターを表示しない
		if ($this->_model_common->checkvalue($this->_params, "OemCd")) {
			$this->setXPassThroutgh();
		}

		// SEO検索ブロックの挿入
		if ($this->_import_seo_search) {
			$this->_data['seo_search_data']['PREF'] = Apm_Seo::getRandomPref(5);
			$this->_data['seo_search_data']['KODAWARI'] = Apm_Seo::getSeoImpKodawari(3,3);
			$this->_data['seo_search_tpl']  = APPLICATION_PATH . '/modules/common/views/scripts/seo_search.tpl';
		}

		// メインブロック生成
		if (isset($this->_main_helper)) {
			$this->_data['main_block'] = $this->_main_helper->getBlock($this->_data);
		}

		// 表示
		$this->display($this->_display_path);
	}

	/**
	* モバイルAPI処理
	*
	* @access	public
	* @param	array	抽出データ
	*/
	public function mobileApiAct($data)
	{
		$api_data = array();
		$api_data['count'] = count($data);
		$api_data['data'] = $data;
		$this->_api_data = $api_data;
	}

	/**
	 * 検索区分設定
	 * @access  public
	 * @param   string   検索区分
	 * @param   boolean  上書きモード
	 * @return
	 */
	public function setSearchKbn($search_kbn, $controller, $updateFlg = false)
	{
		$this->_SrhKbn     = $search_kbn;
		$this->_controller = $controller;
		// パラメータにセット（上書きモードの場合は強制上書き）
		if (!$this->_model_common->checkvalue($this->_params, "SrhKbn") || $updateFlg) {
			$this->_params['SrhKbn'] = $search_kbn;
		}
	}

    /**
     * 検索区分設定（現在、未使用）
     * @access  public
     * @param   string   検索区分
     * @return  array    物件一覧で使用するhiddenデータ
     */
    public function setRstobiData($search_kbn)
    {
    	$array = array();
    	// 検索区分
    	$array['SrhKbn']        = $search_kbn;
    	// 表示区分
    	$array['RstobiDispKbn'] = 1;
    	// ページ番号
    	$array['page']          = 1;
    	// 店舗から部屋検索ページ番号
    	$array['shop_page']     = 1;
    	return Apm_Util::generateHiddenTag($array);
    }

    /**
     * 店舗URL設定
     */
    public function setUrlParams()
    {
    	$url = array();

    	$url['tellist_index']  = Apm_Config_Shop::URL_TELLIST_INDEX;
    	$url['tellist_index2'] = Apm_Config_Shop::URL_TELLIST_INDEX2;
    	$url['index']          = Apm_Config_Shop::URL_INDEX;
    	$url['select_pref']    = Apm_Config_Shop::URL_SELECT_PREF;
    	$url['select_city']    = Apm_Config_Shop::URL_SELECT_CITY;
    	$url['select_rail']    = Apm_Config_Shop::URL_SELECT_RAIL;
    	$url['list']           = Apm_Config_Shop::URL_LIST;
    	$url['detail']         = Apm_Config_Shop::URL_DETAIL;
    	$url['map']            = Apm_Config_Shop::URL_MAP;
    	$url['tenpo_oem_jump'] = Apm_Config_Shop::URL_TENPO_OEM_JUMP;

       	$this->_data['url'] = $url;
    }

	/*
	 * パンくずを生成
	 * @return void
	 */
	public function _setBreadcrumb()
	{
		if ($this->_isInline) return;

		if (!$this->_noMakeBreadcrumb) {
			// 静的URLからの遷移かチェック
			if(empty($this->_static_pattern))
			{
				// **動的URLのパンくず設定**
				$_model_breadcrumb = new Search_Model_Breadcrumb($this->_breadcrumb);

				// パラメータが存在しないorパンくず数が1以下の場合、初期化
				if (empty($this->_params) || $this->_breadcrumb->getCountPankuzu() <= 1)
				{
					$this->_breadcrumb->reset();
					$this->_breadcrumb->add(Apm_Config_Search::BREADCRUMB_TOP, $this->_baseurl);
				}
				if ($this->_breadcrumb->getCountPankuzu() > 1)
				{
					$bread_data = $this->_breadcrumb->getDataByIndex(1);
					$bread_key  = $bread_data['key'];
					// 住居形態以外で、KEY=controllerでない場合、初期化
					if ($bread_key != Apm_Bukkenbreadcrumb::SRH_BREAD_KBN.$this->_params['SrhKbn']
					 && !(($bread_key == Apm_Bukkenbreadcrumb::SRH_BREAD_KBN.Apm_Config_Search::SRHKBN_JYUKYOKEITAI
					       || $bread_key == Apm_Bukkenbreadcrumb::SRH_BREAD_KBN.Apm_Config_Search::SRHKBN_KODAWARI)
						 && ($this->_params['SrhKbn'] == Apm_Config_Search::SRHKBN_JYUSYO || $this->_params['SrhKbn'] == Apm_Config_Search::SRHKBN_ENSENEKI
						   || $this->_params['SrhKbn'] == Apm_Config_Search::SRHKBN_JYUKYOKEITAI || $this->_params['SrhKbn'] == Apm_Config_Search::SRHKBN_KODAWARI))
					 && !($this->_SrhKbn == Apm_Config_Search::SRHKBN_JYUKYOKEITAI)
					 && !($this->_SrhKbn == Apm_Config_Search::SRHKBN_YACHINSOUBA)
					 && !($this->_SrhKbn == Apm_Config_Search::SRHKBN_BUKENREQUEST && $bread_key == 'NEW_REQUEST')) {
						$this->_breadcrumb->reset();
						$this->_breadcrumb->add(Apm_Config_Search::BREADCRUMB_TOP, $this->_baseurl);
					}
				}
				if ($this->_breadcrumb->getCountPankuzu() == 1 && $this->_params['SrhKbn'] == Apm_Config_Search::SRHKBN_BUKENREQUEST) {
					$this->_breadcrumb->add('おまかせ物件リクエスト', $this->_baseurl.'info/request/', 'NEW_REQUEST');
				}
				// 現在地のパンくずを設定
				$_model_breadcrumb->_getCurrentBreadcrumb($this->_params, $this->_data['research_data'], $this->_controller);

			}
			else
			{
				// **静的URLのパンくず生成**
				Apm_Bukkenbreadcrumb::generateBukkenbreadcrumb($this->_static_params, $this->_data['research_data'], $this->_breadcrumb);
			}
		}

		$this->setBreadCrumb($this->_breadcrumb->generateBreadcrumb());
	}

	/**
	 * 法人サイト共通設定
	 *
	 * @access public
	 * @return void
	 */
	public function setAsnnetCommon()
	{
		// データ設定
		$this->_data['ComId']        = $this->_params['ComId'];
		$this->_data['ComGenruFlg']  = $this->_params['ComGenruFlg'];
		$this->_data['strComName']   = $this->_params['strComName'];
		$this->_data['BrowserTitle'] = $this->_params['BrowserTitle'];
		$this->_data['KoujyoRitsu']  = $this->_params['KoujyoRitsu'];
		$this->_data['RequestFlg']   = $this->_params['RequestFlg'];
		$this->_data['EtcFlg']       = $this->_params['EtcFlg'];
		
		// ヘッダー・フッター設定
		$_asmember_header_helper = $this->getApmHelper(APPLICATION_PATH . '/modules/asnnet/views/helpers/header_helper.tpl');
		$_asmember_footer_helper = $this->getApmHelper(APPLICATION_PATH . '/modules/asnnet/views/helpers/footer_helper.tpl');
		$block = array();
		$block['header'] = $_asmember_header_helper->getBlock($this->_data);
		$block['footer'] = $_asmember_footer_helper->getBlock($this->_data);
		$this->_data['asnnetblock'] = $block;
	}

}
?>